<?php

class Cookie
{
    /**
     * 添加一个cookie
     * @param string $name
     * @param $value
     * @param int $minute
     */
    public static function set(string $name, $value, int $minute = 0)
    {
        if ($minute == 0) {
            $minute = time() + 3600 * 24 * 365;
        }
        setcookie($name, $value, $minute, '/');
    }

    /**
     * 获取一个cookie
     * @param string $name
     * @return mixed|null
     */
    public static function get(string $name)
    {
        return @$_COOKIE[$name] ?? null;
    }

    /**
     * 删除一个cookie
     * @param string $name
     */
    public static function delete(string $name)
    {
        setcookie($name, null, time() - 100000000, '/');
    }
}